<template>
  <PageWrapper title="关于">
    <template #headerContent>
      <div class="flex items-center justify-between">
        <span class="flex-1">
          <a :href="GITHUB_URL" target="_blank">sumuze.admin</a>
          是一个基于Vue3.0、Vite、 Ant-Design-Vue 、TypeScript
          的后台解决方案，目标是为中大型项目开发,提供现成的开箱解决方案及丰富的示例,原则上不会限制任何代码用于商用。
        </span>
      </div>
    </template>
      <Description @register="infoRegister" class="enter-y" />
      <Description @register="infoRegisteruse" class="enter-y" />
    <!--     <Description @register="register" class="my-4 enter-y" />
    <Description @register="registerDev" class="enter-y" /> -->
  </PageWrapper>
</template>

<script lang="ts">
  import { defineComponent, h, ref } from 'vue';

  import { Tag } from 'ant-design-vue';
  import { PageWrapper } from '/@/components/Page';
  import { Description, DescItem, useDescription } from '/@/components/Description/index';

  import { SITE_URL, DOC_URL } from '/@/settings/siteSetting';
  import {database, infoDatause} from './api'
  import { machineapi} from '../../system-api';
  export default defineComponent({
    name: 'AboutPage',
    components: { Description, PageWrapper },
    setup() {
      const { pkg, lastBuildTime } = __APP_INFO__;
      const GITHUB_URL = ref('https://gitee.com/jokerhuman/admin.net-vue3-vben');
      const { dependencies, devDependencies, name, version } = pkg;

      const schema: DescItem[] = [];
      const devSchema: DescItem[] = [];

      const commonTagRender = (color: string) => (curVal) => h(Tag, { color }, () => curVal);
      const commonLinkRender = (text: string) => (href) => h('a', { href, target: '_blank' }, text);

      const infoSchema: DescItem[] = [
        {
          label: '版本',
          field: 'version',
          render: commonTagRender('blue'),
        },
        {
          label: '最后编译时间',
          field: 'lastBuildTime',
          render: commonTagRender('blue'),
        },
        {
          label: '主机名称',
          field: 'hostName',
        },
        {
          label: '操作系统',
          field: 'systemOs',
        },
        {
          label: '系统架构',
          field: 'osArchitecture',
        },
        {
          label: '运行框架',
          field: 'frameworkDescription',
        },
        {
          label: 'CPU核数',
          field: 'processorCount',
        },
        {
          label: '外网信息',
          field: 'wanIp',
        },
        {
          label: 'IPv4地址',
          field: 'lanIp',
        },

        {
          label: '网卡MAC',
          field: 'ipMac',
        },
        {
          label: '流量统计',
          field: 'sendAndReceived',
        },
        {
          label: '网络速度',
          field: 'networkSpeed',
        },
      ];
      const infoSchemause: DescItem[] = [
        {
          label: '运行时间',
          field: 'runTime',
        },
        {
          label: 'CPU使用率',
          field: 'cpuRate',
        },
        {
          label: '总内存',
          field: 'totalRam',
        },
        {
          label: '内存使用率',
          field: 'ramRate',
        },
      ];
      const infoData = {
        version,
        lastBuildTime,
        ...database,
      };

      Object.keys(dependencies).forEach((key) => {
        schema.push({ field: key, label: key });
      });

      Object.keys(devDependencies).forEach((key) => {
        devSchema.push({ field: key, label: key });
      });

      const [register] = useDescription({
        title: '生产环境依赖',
        data: dependencies,
        schema: schema,
        column: 3,
      });

      const [registerDev] = useDescription({
        title: '开发环境依赖',
        data: devDependencies,
        schema: devSchema,
        column: 3,
      });

      const [infoRegister] = useDescription({
        title: '系统信息',
        data: infoData,
        schema: infoSchema,
        column: 2,
      });
      const [infoRegisteruse] = useDescription({
        title: '硬件信息',
        data: infoDatause,
        schema: infoSchemause,
        column: 2,
      });
      return { register, registerDev, infoRegister, infoRegisteruse, name, GITHUB_URL };
    },
  });
</script>
